package com.le.tester.javaThink.fifth.chapter14_StreamingProgramming;


import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.regex.Pattern;
import java.util.stream.Stream;

/**
 * 描述：读取文件中的内容
 */
public class FileToWords {

    public static Stream<String> stream(String filePath) throws IOException {
        return Files.lines(Paths.get(filePath))
                .skip(1).flatMap(line -> Pattern.compile("\\W+").splitAsStream(line));
    }
}
